import request from "@/utils/request"

/**
 * 用户信息 前端接口
 *
 * @author haojun
 * @since 2022-06-12
 */
export default class UserApi {
  static page(data) {
    let { pageIndex, pageSize, ...vo } = data
    return request.post(`/user/page/${pageIndex}/${pageSize}`, vo)
  }

  static list(data) {
    return request.post("/user/list", data)
  }

  static getById(id) {
    return request.get(`/user/${id}`)
  }

  static save(data) {
    return request.post("/user", data)
  }

  static update(data) {
    return request.put("/user", data)
  }

  static delete(id) {
    return request.delete(`/user/${id}`)
  }

  static deleteByIds(ids) {
    return request.delete("/user", ids)
  }

  static changeAvatar(data) {
    return request.post("/user/changeAvatar", data)
  }

  static changePwd(data) {
    return request.post("/user/changePwd", data)
  }

  static resetPwd(data) {
    return request.post("/user/resetPwd", data)
  }

  static getRoles(userId) {
    return request.get(`/user/roles/${userId}`)
  }

};

export function login(data) {
  return request.post("/login", data)
}

export function getInfo() {
  return request.get("/current")
}

export function logout() {
  return request.get("/logout")
}
